<template>
  <div class="tuan">
    <div class="top">
      <div class="title">爆爆团</div>
      <div class="intro">限时爆款 超级低价</div>
    </div>
    <div class="list">
      <div class="topic">
        <span v-for="(item, index) in topic" :key="index" @click="handleClick(index)">{{ item }}</span>
      </div>
      <div class="itemlist">
        <div class="item" v-for="(item, index) in tasklist" :key="index">
          <img :src="item.picture" alt="" />
          <div class="right">
            <div class="name">{{ item.name }}</div>
            <div class="msg"></div>
            <div class="price">
              <div class="zuo">
                <div>爆爆团价</div>
                <div>￥{{ item.min_price }}</div>
              </div>
              <div class="qiang">马上抢</div>
            </div>
            <div class="prev">
              <span class="before">￥50</span>
              <span class="count">{{ item.month_saled_content }}</span>
            </div>
          </div>
        </div>
      </div>  
    </div>
  </div>
</template>

<script>
import { tuan } from "../../api/index";
export default {
  data() {
    return {
      tasklist: [],
      topic: ["正在抢购", "上新预告"],
      suoyin:0,
      bianliang:0
    };
  },
  mounted() {
    tuan({ status: this.bianliang }).then((res) => {
      console.log(res.data.list);
      this.tasklist = res.data.list;
    });
  },
  methods:{
    handleClick(index){
      this.suoyin = index
      if(this.suoyin == 0){
        this.bianliang = 1
      }else{
        this.bianliang = 0
      }
      console.log(this.bianliang);
     tuan({ status: this.bianliang }).then((res) => {
      console.log(res.data.list);
      this.tasklist = res.data.list;
    });
    }
  }
};
</script>

<style scoped>
.tuan {
  background: linear-gradient(red, rgba(225, 180, 96, 0.8), rgb(243, 237, 237));
}
.top {
  height: 250px;
  width: 100%;
  color: white;

  text-align: center;
}
.top .title {
  font-size: 20px;
  padding: 30px;
}
.top .intro {
  font-size: 26px;
}
.list {
  height: 500px;
  padding: 10px;
  margin-top: -100px; 
}
.list .topic {
  height: 50px;
  color: white;
}
.list .topic span {
  margin-right: 20px;
}
.list .itemlist{
  height: 450px;
  overflow: auto;
}
::-webkit-scrollbar {
  display: none;
}
.list .item {
  background-color: white;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 5px;
  display: flex;
}
.list .item img {
  width: 80px;
  height: 80px;
}
.list .item .right {
  width: 100%;
  padding-left: 10px;
}
.list .item .right .name{
  color: gray;
  font-size: 16px;
  font-weight: 700;
}
.list .item .right .price{
  display: flex;
  padding: 5px;
  justify-content: space-between;
}
.list .item .right .price .qiang{
  width: 80px;
  height: 30px;
  background-color: red;
  color: white;
  text-align: center;
  line-height: 30px;
  border-radius: 20px;
}
.list .item .right .zuo :nth-child(1){
  color: red;
  font-size: 12px;
}
.list .item .right .zuo :nth-child(2){
  color: red;
  font-size: 16px;
  font-weight: 700;
}
.list .item .right .prev{
  display: flex;
  justify-content: space-between;
}
.list .item .right .prev .before{
  text-decoration: line-through;
  color: gray;
  font-size: 12px;
}
.list .item .right .prev .count{
  color: red;
  font-size: 12px;
}
</style>